package com.tang.algorithm.ordinary;

import java.util.HashMap;
import java.util.HashSet;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/6/1 22:23
 * https://leetcode-cn.com/problems/jewels-and-stones/
 *
 * 宝石与石头
 */
public class LeetCode771 {

    public int numJewelsInStones(String J, String S) {
        HashSet<Character> set = new HashSet<>();
        int count=0;
        for (int i = 0; i <J.length() ; i++) {
            set.add(J.charAt(i));
        }
        for (int i = 0; i <S.length() ; i++) {
            if(set.contains(S.charAt(i)))count++;
        }

        return count;
    }
}
